<?php
/*
Template Name: Blog Template
*/
?>
<?php get_header(); ?>

<script type="text/javascript" language="javascript">
	$(window).load(function(){
	
		var height = $('.image_date_container .image img').height();
		var marginTop = ((height-200)/2)*-1;		
		$('.image_date_container .image img').css('margin-top', marginTop+'px' );
		$('.image_date_container .image img').animate({
			'opacity':'1',
			'filter': 'alpha(opacity = 100)'
		}, 1000);
	
	});
	
	$(document).ready(function(){
		if ($('#getguid').html() != ""){
			$('.menu').find('a').each(function(){
				if ($(this).attr('href') === $('#getguid').html()){
					$(this).addClass('selected');
					return false;
				}
			});
		}
	});

</script>

			<div class="contentautoheight archive">
				<div class="titlepage">
					<p><span><?php /* If this is a category archive */ if (is_category()) { ?>
						Archive for '<?php single_cat_title(); ?>'
						<?php /* If this is a tag archive */ } elseif( is_tag() ) { ?>
						Posts Tagged '<?php single_tag_title(); ?>'
						<?php /* If this is a daily archive */ } elseif (is_day()) { ?>
						Archive for <?php the_time('F jS, Y'); ?>
						<?php /* If this is a monthly archive */ } elseif (is_month()) { ?>
						Archive for <?php the_time('F, Y'); ?>
						<?php /* If this is a yearly archive */ } elseif (is_year()) { ?>
						Archive for <?php the_time('Y'); ?>
						<?php /* If this is an author archive */ } elseif (is_author()) { ?>
						Author Archive
						<?php /* If this is a paged archive */ } elseif (isset($_GET['paged']) && !empty($_GET['paged'])) { ?>
						Blog Archives<?php } else the_title(); ?></span></p>
				</div>
				<div class="slideimg">
					<div class="autoheight" style="padding-bottom: 0px;">
					
						<div class="blog_container">
							<div class="blog_content">
								<div class="blog_title">
									<?php /* If this is a category archive */ if (is_category()) { ?>
									Archive for '<?php single_cat_title(); ?>'
									<?php /* If this is a tag archive */ } elseif( is_tag() ) { ?>
									Posts Tagged '<?php single_tag_title(); ?>'
									<?php /* If this is a daily archive */ } elseif (is_day()) { ?>
									Archive for <?php the_time('F jS, Y'); ?>
									<?php /* If this is a monthly archive */ } elseif (is_month()) { ?>
									Archive for <?php the_time('F, Y'); ?>
									<?php /* If this is a yearly archive */ } elseif (is_year()) { ?>
									Archive for <?php the_time('Y'); ?>
									<?php /* If this is an author archive */ } elseif (is_author()) { ?>
									Author Archive
									<?php /* If this is a paged archive */ } elseif (isset($_GET['paged']) && !empty($_GET['paged'])) { ?>
									Blog Archives<?php } else the_title(); ?>
								</div>

			<?php query_posts('showposts=5'); ?>

			<?php if ( have_posts() ) : ?>

				<?php /* Start the Loop */ ?>
				<?php while ( have_posts() ) : the_post(); ?>
				
					<?php $date = explode("-", $post->post_date); $day = explode(" ", $post->post_date);
						$month = "";
						switch($date[1]){
							case "01": $month = "Jan"; break;
							case "02": $month = "Feb"; break;
							case "03": $month = "Mar"; break;
							case "04": $month = "Apr"; break;
							case "05": $month = "May"; break;
							case "06": $month = "Jun"; break;
							case "07": $month = "Jul"; break;
							case "08": $month = "Aug"; break;
							case "09": $month = "Sep"; break;
							case "10": $month = "Oct"; break;
							case "11": $month = "Nov"; break;
							case "12": $month = "Dec"; break;
						}
						
					?>

					<div <?php post_class() ?>>
				
					<h2 id="post-<?php the_ID(); ?>"><a style="padding-bottom: 10px;font-family: Tahoma; font-size: 18px; font-weight: bold; line-height: 18px; color: #2C7FA2;" href="<?php the_permalink() ?>"><?php the_title(); ?></a></h2>
					
					<div id="gotimage-<?php the_ID(); ?>" style="display:none; visibility: hidden;"><?php echo wp_get_attachment_url( get_post_thumbnail_id($post->ID) ); ?></div>
					
					<div class="image_date_container image-id-<?php the_ID(); ?>">
						<div class="image">
							<a href="<?php the_permalink() ?>">
								<img alt="<?php the_title() ?>" src="<?php echo wp_get_attachment_url( get_post_thumbnail_id($post->ID) ); ?>"/>
							</a>
						</div>
						<div class="date_corner">
							<div class="month"><?php echo $month; ?></div>
							<div class="day"><?php echo substr($date[2], 0, 2); ?></div>
						</div>
					</div>

					<script type="text/javascript" language="javascript">
						if ($('#gotimage-<?php the_ID(); ?>').html() === "") $('.image-id-<?php the_ID(); ?>').remove();
					</script>
					
					<?php /* include (TEMPLATEPATH . '/inc/meta.php' ); */ get_template_part( 'meta' ); ?>
					
					<div class="entry" style="font-family: Tahoma; font-size: 13px; line-height: 18px; color: #7A7A7A;">
						<?php wpe_excerpt('wpe_excerptlength_archive', 'wpe_excerptmore'); ?>	
					</div>
					
					<div class="readmore"><a href="<?php the_permalink() ?>"><?php _e("Read More"); ?></a></div><br/>
					
					

				</div>
				
				<div id="getguid" style="color:black; display:none;"><?php //print_r($post);
					
					$querystr = "
						SELECT post_id
						FROM $wpdb->postmeta
						WHERE meta_value = 'template-blog.php'
					";
					
					$pageposts = $wpdb->get_results($querystr, OBJECT);
					$post_id = $pageposts[0]->post_id;
					
					$querystr = "
						SELECT guid
						FROM $wpdb->posts
						WHERE ID = ".$post_id."
					";
					
					$pageposts = $wpdb->get_results($querystr, OBJECT);
					$guid = $pageposts[0]->guid;
				
					echo $guid; ?></div>

			<?php endwhile; ?>
			
			<?php /* include (TEMPLATEPATH . '/inc/nav.php' ); */ get_template_part( 'nav' ); ?>

			<?php else : ?>

		<h2>Nothing found</h2>

	<?php endif; ?>
								
																
							</div>
							<div class="bgbottom"></div>
						</div>
						
						
						<!-- SIDEBAR -->
						<div class="blog_sidebar">
														
							<?php get_sidebar(); ?>
						
						</div>
						
						
					</div>
					<div class="hidecorner"></div>
				</div>
			</div>

<?php get_sidebar(); ?>

<?php get_footer(); ?>